Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataViews list layout: hide actions menu when there is only one action and is primary #67015

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Nov 14, 2024

Part of #65165

What?

This PR hides the actions menu for the DataViews list layout when there's only 1 action and is primary.

Before After
Screenshot 2024-11-14 at 20 00 19 Screenshot 2024-11-14 at 19 59 53

All current core screens have more than one action. See testing instructions below.

Why?

To improve UX.

How?

Testing Instructions

This is something we've heard from extenders. Because there's no place in core where we have this situation just yet, we have to create one for testing:

  • Go to the post-list code and remove the postTypeActions in this line and in the line below (in both arrays).
  • Visit the Pages page and verify only the edit icon is displayed.
Screen.Recording.2024-11-14.at.19.59.25.mov

@oandregal oandregal self-assigned this Nov 14, 2024
Copy link

github-actions bot commented Nov 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Package] DataViews /packages/dataviews labels Nov 14, 2024
@@ -175,6 +175,8 @@ function ListItem< Item >( {
};
}, [ actions, item ] );

const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this checks actions, not eligibleActions. This is intentional to make sure that we only hide the item menu when all the items has a single action. We wouldn't want to show only the icon for some and the icon + the actions menu for others.

Copy link

Flaky tests detected in 3fb8ef7.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11843760531
📝 Reported issues:

@oandregal oandregal changed the title DataViews List layout: hide actions menu when there is only one action and is primary DataViews list layout: hide actions menu when there is only one action and is primary Nov 15, 2024
@oandregal oandregal requested a review from ellatrix November 15, 2024 07:03
@oandregal oandregal requested a review from Mamaduka November 15, 2024 08:32
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected ✅

P.S. Nitpick: The Array.filter will always return an array. There's no need for optional chaining on this line.

primaryAction: _primaryActions?.[ 0 ],

@oandregal
Copy link
Member Author

P.S. Nitpick: The Array.filter will always return an array. There's no need for optional chaining on this line.

👍 Pushed 6f9eaff

@oandregal oandregal enabled auto-merge (squash) November 15, 2024 09:18
@oandregal oandregal merged commit a750125 into trunk Nov 15, 2024
62 checks passed
@oandregal oandregal deleted the hide/actions-menu-list branch November 15, 2024 09:54
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 15, 2024
@bph bph added the [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants